package study.java.jdk.jdk8._1_stream.collectors.summary;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import study.java.jdk.jdk8.DataUtils;
import study.java.jdk.jdk8.User;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
public class summing_Test {

    private List<User> userLt = DataUtils.buildUserLt();

    /**
     * @param mapper
     */
    @Test
    public void test1() {
        int sum = userLt.stream()
                .collect(Collectors.summingInt(User::getAge));
        log.info("sum= {}", sum);
    }

    @Test
    public void test2() {
        long sum = userLt.stream()
                .collect(Collectors.summingLong(User::getAge));
        log.info("sum= {}", sum);
    }

    @Test
    public void test3() {
        double sum = userLt.stream()
                .collect(Collectors.summingDouble(User::getAge));
        log.info("sum= {}", sum);
    }
}
